import Vue from 'vue';
import Vuex from 'vuex';
// 导入 获取用户信息接口
import request from '../utils/request';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    // token
    token: '',
  },
  mutations: {
    getToken(state, token) {
      state.token = token;
    },
  },
  actions: {
    //  获取用户信息
    getUserInfoX(context) {
      request({
        method: 'post',
        url: '/user/currentUser',
        header: { Authorization: localStorage.getItem('token') },
      }).then(res => {
        console.log(res);
      });
      console.log(123);
      console.log(localStorage.getItem('token'));
    },
  },
  modules: {},
});
